import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { TransportRewardPanel } from "./TransportRewardPanel";
import { TransportInfo } from "../../model/TransportInfo";
import { EffectManager } from "../../manager/EffectManager";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { SWFInfo } from "../../../../com/gengine/resource/info/SWFInfo";
type int = number;
//class TransportItem
    
    export  class TransportItem /* flash.display.Sprite */
    {
        constructor(arg1: int)
        {
            
            this._color = arg1;
            mouseChildren = false;
            mouseEnabled = false;
            this.initUI();
            return;
        }

        public get color(): int
        {
            return this._color;
        }

        protected initUI(): void
        {
            this._cloudBmp = new Object /* flash.display.Bitmap */();
            LoaderHelp.addResCallBack(ResFileConst.transport, this.onTransportLoadedHandler);
            LoaderManager.instance.load("TransportCloud.swf", this.onCloudLoadedHandler);
            LoaderManager.instance.load("TransportItem" + this._color + ".swf", this.onItemLoadedHandler);
            this._rewardPanel = new TransportRewardPanel(this._color);
            return;
        }

        public updateData(arg1: TransportInfo): void
        {
            this._rewardPanel.updateData(arg1);
            return;
        }

        public updateFilter(arg1: Boolean): void
        {
            if (this._filter == arg1) 
            {
                return;
            }
            this._filter = arg1;
            this.refreshFilter();
            return;
        }

        /* internal  */refreshFilter(): void
        {
            if (this._itemMC) 
            {
                if (this._filter) 
                {
                    EffectManager.glowFilterReg(this._itemMC, [FilterConst.guideTipsFilter], 0.6, 15, 5);
                }
                else 
                {
                    EffectManager.glowFilterUnReg(this._itemMC);
                }
            }
            return;
        }

        /* internal  */updateLayout(): void
        {
            if (this._cloudBmp && this._fontBmp && this._itemMC) 
            {
                this._cloudBmp.x = 46;
                this._cloudBmp.y = 25;
                this._itemMC.x = this._cloudBmp.x + (this._cloudBmp.width - this._itemMC.width) / 2 + 20;
                this._itemMC.y = this._cloudBmp.y + this._cloudBmp.height - this._itemMC.height - 15;
                var loc1=this._color;
                switch (loc1) 
                {
                    case 1:
                    {
                        this._fontBmp.x = 25;
                        this._fontBmp.y = 7;
                        break;
                    }
                    case 2:
                    {
                        this._fontBmp.x = 30;
                        this._fontBmp.y = 7;
                        break;
                    }
                    case 3:
                    {
                        this._fontBmp.x = this._cloudBmp.width / 2 + 40;
                        this._fontBmp.y = 7;
                        break;
                    }
                    case 4:
                    {
                        this._fontBmp.x = -50;
                        this._fontBmp.y = 60;
                        break;
                    }
                    case 5:
                    {
                        this._fontBmp.x = this._cloudBmp.width / 2 + 30;
                        this._fontBmp.y = 12;
                        break;
                    }
                }
                addChild(this._cloudBmp);
                addChild(this._itemMC);
                addChild(this._fontBmp);
                addChild(this._rewardPanel);
                this._rewardPanel.x = this._cloudBmp.x + this._cloudBmp.width - 35;
                this._rewardPanel.y = this._cloudBmp.y + this._cloudBmp.height / 2;
            }
            return;
        }

        /* internal  */onTransportLoadedHandler(): void
        {
            this._fontBmp = GlobalClass.getBitmap("transportName_" + this._color);
            this.updateLayout();
            return;
        }

        /* internal  */onCloudLoadedHandler(arg1: SWFInfo): void
        {
            if (arg1 && arg1.bitmapData) 
            {
                this._cloudBmp.bitmapData = arg1.bitmapData;
                this.updateLayout();
            }
            return;
        }

        /* internal  */onItemLoadedHandler(arg1: SWFInfo): void
        {
            if (arg1 && arg1.clip) 
            {
                this._itemMC = arg1.clip;
                this.refreshFilter();
                this.updateLayout();
            }
            return;
        }

        public dispose(): void
        {
            this._filter = false;
            if (this._itemMC) 
            {
                EffectManager.glowFilterUnReg(this._itemMC);
            }
            return;
        }

        public /* override */ get height(): number
        {
            return 140;
        }

        public /* override */ get width(): number
        {
            var loc1=this._color;
            switch (loc1) 
            {
                case 1: case 2: case 3:
                {
                    return 230;
                }
                case 4: case 5:
                {
                    return 270;
                }
            }
            return super.width;
        }

        /* internal */ /* var */_color: int;

        /* internal */ /* var */_itemMC: Object /* flash.display.MovieClip */;

        /* internal */ /* var */_cloudBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_fontBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_rewardPanel: TransportRewardPanel;

        /* internal */ /* var */_filter: Boolean;
    }
